"""
@author: 江同学呀
@file: build_add_attr.py
@date: 2024/7/26 10:45
@desc: 
"""
from typing import Callable, Dict


def build_add_attr(func: Callable):
    """
    构建时添加属性
    :rtype: object
    :param func:
    :return:
    """

    def wrapper(self, *args, **kwargs) -> Dict:
        """

        :param self:
        :param args:
        :param kwargs:
        :return:
        """
        mapping: Dict = func(self, *args, **kwargs)
        if self._attr_method_list:
            mapping.update(
                k_v for attr_method in self._attr_method_list if (k_v := attr_method()) and k_v[1] is not None
            )
            pass
        return mapping
    return wrapper

